package com.xuantu.learn.core.thread;

public class ThreadCommunication {

	private static int num;// 定义一个变量作为数据

	public static void main(String[] args) {
		Thread threadA = new Thread(new Runnable() {

			@Override
			public void run() {
				try {
					Thread.sleep(1000);
					num = 1;
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}

		});
		Thread threadB = new Thread(new Runnable() {

			@Override
			public void run() {
				System.out.println(Thread.currentThread().getName() + "获取到 num 的值为：" + num);
			}

		});
		Thread threadC = new Thread(new Runnable() {

			@Override
			public void run() {
				System.out.println(Thread.currentThread().getName() + "获取到 num 的值为：" + num);
			}

		});
		
		threadA.start();
		threadB.start();
		threadC.start();
	}

}
